const path = require('path');
const fs = require('fs');

function createAccessWriteStrean () {
    const filename = path.join(__dirname, '../', '../', 'logs/access.log');
    return fs.createWriteStream(filename, {
        flags: 'a' // append 追加写入
    });
}

/**
 * 写入 access log
 * @param log
 */
function access (log) {
    const writeStream = createAccessWriteStrean();
    writeStream.write(`${log}\n`);
}

module.exports = {
    access
};
